//Lock.hpp
//对锁进行一个封装，RAII
#pragma once
#include <pthread.h>
#include <iostream>
using namespace std;
class Lock_Guard
{
    public:
    Lock_Guard(pthread_mutex_t* mutex)
    :_mutex(mutex)
    {
        pthread_mutex_lock(_mutex);
    }
    //构造函数的时候加锁，析构函数的时候解锁
    ~Lock_Guard()
    {
        pthread_mutex_unlock(_mutex);
    }

    private:
    pthread_mutex_t* _mutex;
};